import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Demo28 {
    public static void main(String[] args) {
        //创建一个线程池，把任务提交给线程池里面的线程去执行任务
        ExecutorService executorService =Executors.newCachedThreadPool(); //创建一个线程池的实例
        for (int i = 0; i < 1000; i++) {
            final int id=i;
            executorService.submit(new Runnable() {
                @Override
                public void run() {
                    String name=Thread.currentThread().getName();
                    System.out.println("hello"+name+"," +id);
                }
            });
        }

    }
}
